<?php 
$sql =	"SELECT
			  c.page_id,
			  d.title,
			  d.description,
			  d.meta_key,
			  d.meta_description	
		  FROM
			  pages AS c,
			  page_description AS d,
			  sef_url AS s
		  WHERE
		  
			  c.page_id = d.page_id
			  AND
			  d.lang_id = '".$_SESSION['lang_id']."'
			  
			  AND
				c.page_id = s.query
				AND
				s.lang_id = '".$_SESSION['lang_id']."'
				AND s.tamplate = 'page'
			 
			  AND
				s.sef_url = 'contacts' 
		  ";


$result = query($sql);
$row = mysql_fetch_object($result);

head(sth($row->title),sth($row->meta_description));

$coor = explode(",", $row->meta_key)

?>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?v=3&amp;sensor=false"></script>
<script type="text/javascript" src="<?=HTML_BASE?>js/contacts_map.js"></script>
   
    <section id="content" class="cf">
   	    <h1><?=$row->title?></h1>
        
        <div class="gr2 left">
           <div class="tab">
                <h1><?=stripslashes($row->title)?></h1>
                <?=stripslashes($row->description)?>

                <div id="contact-map"></div>
                <script type="text/javascript">
                    initialize("<?=$coor[0]?>","<?=$coor[1]?>");
                </script>
          </div>
        </div>
        
        
        <div class="gr2 right light-gray">   
            <div class="tab"> 
                <h1><?=__Contact_form?></h1>

                <form id="contact-form" >
                <div class="message"></div>
                <p><?=__name?>:</p>
                <input type="text" name="name">

                <p><?=__Email?>:</p>
                <input type="email" name="email">

                <p><?=__Enquiry?>:</p>
                <textarea name="message"></textarea>
                <p><a class="button" onclick="send_contact_form(); return false;"><?=__Send?></a></p>

                </form>
            </div>
        </div>
        
        
<!--
        <div class="gr1 left">
            <a href="#tab1" class="blue tablink">
                <?=__CONTACTS?>
            </a>
        </div>
        <div class="gr1 left">
            <a href="#tab2" class="green tablink">
                <?=__MAP?>
            </a>
        </div>
        <div class="gr1 left">    
            <a href="#tab3" class="purple tablink">
               <?=__Contact_us?>
            </a>
        </div>
        
        <div class="gr3 left">
           
           <div id="tab1" class="tab blue">
               <h1><?=stripslashes($row->title)?></h1>
               <?=stripslashes($row->description)?>
           </div>
           
           <div id="tab2" class="tab green">
               <div id="contact-map"></div>
               <script type="text/javascript">
                    initialize("<?=$coor[0]?>","<?=$coor[1]?>");
               </script>
           </div>
           
           <div id="tab3" class="tab purple">
               <h1><?=__Contact_form?></h1>
               
                <form id="contact-form" >
                <div class="message"></div>
                <p><?=__name?>:</p>
                <input type="text" name="name">
                
                <p><?=__Email?>:</p>
                <input type="email" name="email">

                <p><?=__Enquiry?>:</p>
                <textarea name="message"></textarea>
				<p><a class="button" onclick="send_contact_form(); return false;"><?=__Send?></a></p>
                
                </form>
            </div>
-->
           
        </div>
        
    </section>



<script type="text/javascript">
		
function IsEmail(email) {
      var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
      return regex.test(email);
    }

function send_contact_form()
{
    $('#contact-form input,select,textarea').removeClass('redborder');
    var error = '';
    $( '#contact-form input,textarea').each(function() {

        if(!$( this ).val()){
             $( this ).addClass('redborder');
             error += $( this ).attr('name')+',';
        }else{

            if($( this ).attr('name') == 'email'  && !IsEmail($( this ).val()) )
            {
                 error += $( this ).attr('name')+',';
                 $( this ).addClass('redborder');
            }

        }
    });


    if(!error)
    {

        var json = '{'
        $( '#contact-form input,textarea').each(function() {

            json += '"'+$( this ).attr('name')+'":"'+$( this ).val()+'",';
        });
            json += '"send":"true"';
        json += '}';

        json = JSON.stringify(json);

         $.ajax({
                    type: 'POST',
                    url:'<?=HTML_BASE?>send.php',
                    data: 'type=contact&alldata=' +json,
                    success: function(msg){
                                $('#contact-form .message').html('<?=__Message_sent?>');
                                $('#contact-form .message').slideDown().delay(4000).slideUp();	
                            },
                    error: function(msg){
                                $('#contact-form .message').html('Error:'+ msg);
                                $('#contact-form .message').slideDown().delay(4000).slideUp();
                            }
                });
        $('#contact-form').find("input,textarea").val("");

    }
}
</script>  

<?php

foot();
?>